package com.itheima.stock.controller;

import com.itheima.stock.service.UserService;
import com.itheima.stock.vo.req.LoginReqVo;
import com.itheima.stock.vo.resp.CaptchaRespVo;
import com.itheima.stock.vo.resp.LoginRespVo;
import com.itheima.stock.vo.resp.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author byzhao
 * @version 1.0
 * @description 用户表现层
 * @date 2022/10/12 15:20:31
 */
@RestController
@RequestMapping(path = "/api")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping(path = "/test")
    public String test() {
        return "Test";
    }

    /**
     * 用户登录
     *
     * @param loginReqVo
     * @return
     */
    @PostMapping("/login")
    public R<LoginRespVo> login(@RequestBody LoginReqVo loginReqVo) {
        return this.userService.login(loginReqVo);
    }

    /**
     * 生成验证码
     * @return
     */
    @GetMapping("/captcha")
    public R<CaptchaRespVo> generateCaptcha(){
        return userService.generateCaptcha();
    }
}
